#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <stdio.h>


#include "node.h"
#include "display.h"
#include "timer.h"

extern Node *node; /* declarado em main.c nao sei como passar parametro para display via glut, acho q nem tem como :( */

/** Duplicado pq essa porcaria nao funciona chamada de um arquivo serparado pq ? Who knows :( **/
static void renderBString(float x, float y, float z, void *font, char *string) {
  char *c;
  glRasterPos3f(x, y, z);
  for (c=string; *c != '\0'; c++) {
    glutBitmapCharacter(font, *c);
  }
}

void display(void) {
	int count;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	if(node->type == ARRAY || node->type == SIMPLE_LINKED_LIST) {
		for(count = 0; count < node->data_size; count++) {
			float color[] = {1.0, 1.0, 0.0};
			node->draw(node, 0 + 80 * count, 0);
			if(!count) {
				color[0] = 1.0;
				color[1] = 0.6;
				color[2] = 0.0;
				/***
				color[0] = timer[0]->count - timer[0]->count / 1500.0;
				color[1] = 1.0;
				color[2] = timer[0]->count / 1500.0; 
				***/
			}
			node->color(node, color);
			node->render(node);
		}
		node->render(node);

	}
	glFlush();
	glutSwapBuffers();
}


